package com.erp.shop.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.fastjson.JSONObject;
import com.erp.shop.domain.bo.ErpSellerStoreEmpowerBo;
import com.erp.shop.domain.bo.ErpSellerStoreRecordBo;
import com.erp.shop.domain.dto.ErpSellerStoreRecordDto;
import com.erp.shop.domain.dto.ErpSellerStoreSelfEvaluationDto;
import com.erp.shop.domain.vo.ErpSellerStoreRecordVo;
import com.erp.shop.service.IErpSellerStoreEmpowerService;
import com.erp.shop.service.IErpSellerStoreRecordService;
import com.ruoyi.common.core.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.web.oldController.BaseController;
import com.ruoyi.common.core.web.oldPage.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.order.api.RemoteErpOrderService;
import com.ruoyi.order.api.domain.ErpSellerOrder;
import com.ruoyi.shop.api.domain.ErpSellerStoreEmpower;
import com.ruoyi.shop.api.domain.vo.ErpSellerStoreEmpowerVo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.*;

/**
 * @Description: 经公司开通或添加的所有店铺信息列表
 * @Author: j.zh
 * @Date: 2024/7/6
 * @Version: 4.2.0
**/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/seller/store/record")
public class ErpSellerStoreRecordController extends BaseController {

	@Resource
	IErpSellerStoreRecordService erpSellerStoreRecordService;

	/**
	 * 查询店铺信息列表
	 */
	@GetMapping("/list")
	public TableDataInfo<ErpSellerStoreRecordDto> list(ErpSellerStoreRecordBo bo, PageQuery pageQuery) {
		return erpSellerStoreRecordService.queryPageList(bo, pageQuery);
	}

	/**
	 * 新增店铺信息
	 */
	@Log(title = "新增店铺信息", businessType = BusinessType.INSERT)
	@RepeatSubmit()
	@PostMapping()
	public R<Void> add(@Validated(AddGroup.class) @RequestBody ErpSellerStoreRecordBo bo) {
		return toAjax(erpSellerStoreRecordService.insertByBo(bo));
	}

    /**
	 * 修改店铺信息
	 */
	@Log(title = "修改店铺信息", businessType = BusinessType.UPDATE)
	@RepeatSubmit()
	@PutMapping()
	public R<Void> edit(@Validated(EditGroup.class) @RequestBody ErpSellerStoreRecordBo bo) {
		return toAjax(erpSellerStoreRecordService.updateByBo(bo));
	}

	/**
	 * 删除店铺信息
	 *
	 * @param ids 主键串
	 */
	@Log(title = "删除店铺信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
		return toAjax(erpSellerStoreRecordService.deleteWithValidByIds(Arrays.asList(ids), true));
	}


}
